package com.jinzhi.oss.controller;

import com.jinzhi.jzweb.utils.ValuesUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 打包修改类
 * @program: MyWebAppConfiguration
 *  www  8877
 * peixun 8077
 * @author: Kl
 * @create: 2019-12-31 11:48
 **/
@Configuration
public class MyWebAppConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //和页面有关的静态目录都放在项目的static目录下
        registry.addResourceHandler("/upload/**").addResourceLocations("classpath:/upload/");
        //上传的图片在D盘下的OTA目录下，访问路径如：http://127.0.0.1:8888/upload/20191231/f/b/aaa.jpeg
        //其中upload表示访问的前缀。"file:D:/Workspaces/web/upload/"是文件真实的存储路径(项目路径后）
        //本地
        registry.addResourceHandler("/upload/**").addResourceLocations("file:" + ValuesUtil.localUrl + "/upload/");
        //线上
        //registry.addResourceHandler("/upload/**").addResourceLocations("file:C:/Users/Administrator/Desktop/X-jinzhi/upload/");
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addRedirectViewController("/","/login");
            //registry.addViewController("/").setViewName("examinationWeb/login");//证书考试门户-8877,8899
        // registry.addViewController("/").setViewName("cultivateWeb/index");//培训就业门户-8077,8099
        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
        super.addViewControllers(registry);
    }
}


